<?php 

function MiddleTrim($string)
{
	$rule = '/\s{2,}/';
	$ret_string = preg_replace($rule, " ", $string);

	return $ret_string;
}

function JudgeSession()
{
	if ($_SESSION['UserName'] == '' || $_SESSION['PassWord'] == '' || $_SESSION['LoginTime'] == '')
	{
	        echo("<meta http-equiv='refresh'content=0;URL='login.htm'>");
	}
}

function DelEndComma($str)
{
	$ret_array = str_split($str);
	$ret_str = "";
	$end = end($ret_array);

	if ($end == ",")
	{
		array_pop($ret_array) ;
	}
	
	foreach ($ret_array as $ret)
	{
		$ret_str .= $ret;
	}
	
	return $ret_str;
}

function GetSystemLicenseLevel()
{
	$buffer_len = 512;
	$handle = @fopen("/usr/.type", "r");
	$ret = 0;
	if ($handle) 
	{
   		while (!feof($handle)) 
		{
          		$buffer = fgets($handle, $buffer_len);
			if ($buffer > 0 && $buffer < 9) // 1-8
				$ret = $buffer;
		}
		fclose($handle);
	}
	return $ret;
}

function sys_log($m)
{

}
?>
